/**
 * @author: wq
 * @Date: 2017/11/9
 * @Time: 15:08
 * <p>
 * Description:
 *          ***
 */
import axios from 'axios';
import { API_NEW_VERSION } from '../api';

var qs = require('qs');

const ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES = 'order/truck_load_distinguish_services';
const ORDER_TRUCK_LOAD_DISTINGUISH_SERVICE = 'order/truck_load_distinguish_service/';

const ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES_ADDRESS = 'order/truck_load_distinguish_services_address';
const ORDER_TRUCK_LOAD_DISTINGUISH_SERVICE_ADDRESS = 'order/truck_load_distinguish_service_address/';

/**
 * 获取整车分单服务列表API
 * @param params
 * @returns {AxiosPromise}
 */
export const searchTruckLoadDistinguishService = params => {
  return axios.get(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES, {params: params});
};

/**
 * 新增整车分单服务API
 * @param params
 * @returns {AxiosPromise}
 */
export const saveTruckLoadDistinguishService = params => {
  return axios.post(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES, params);
};

/**
 * 根据id，修改状态
 * @param id
 * @param status
 * @returns {AxiosPromise}
 */
export const changeStatus = (id, status) => {
  return axios.post(API_NEW_VERSION + 'order/truck_load_distinguish_service/change', qs.stringify({
    id: id,
    status: status
  }));
};

/**
 *  根据id，删除
 * @param id
 * @returns {AxiosPromise}
 */
export const deleteTruckLoadDistinguishService = id => {
  return axios.delete(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICE + id);
};

/**
 * 获取整车分单服务管辖地址列表API
 * @param params
 * @returns {AxiosPromise}
 */
export const searchTruckLoadDistinguishServiceAddress = params => {
  return axios.get(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES_ADDRESS, {params: params});
};

/**
 * 新增整车分单服务管辖地址API
 * @param params
 * @returns {AxiosPromise}
 */
export const saveTruckLoadDistinguishServiceAddress = params => {
  return axios.post(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICES_ADDRESS, params);
};

/**
 *  根据id，删除管辖地址
 * @param id
 * @returns {AxiosPromise}
 */
export const deleteTruckLoadDistinguishServiceAddress = id => {
  return axios.delete(API_NEW_VERSION + ORDER_TRUCK_LOAD_DISTINGUISH_SERVICE_ADDRESS + id);
};
